<template>
	<view class="page">
		<image class="loginbgImg" src="/static/img/login-bg.png" mode="widthFix"></image>
		<view class="layout nopad" :style="{ marginTop: h + 'px' }">
			<view class="logo">
				<view class="logo1 f fc"><image src="../../static/img/logo1.png" mode=""></image></view>
			</view>
			<view class="wrap">
				<view class="title">北航天汇小程序系统</view>
				<button class="cu-btn block round login  wexColor" open-type="getUserInfo" lang="zh_CN" @getuserinfo="appLoginWx">
					<text class="cuIcon-weixin"></text>
					微信授权登录
				</button>
				<view class="cu-btn block round login " @tap="loginSubmit">
					<text class="cuIcon-lock"></text>
					账号密码登录
				</view>
				<view class="f fb botCpontent">
					<view class="botCont" @click="tonewPoint">预约咨询</view>
					<view class="botCont" @click="toUserRegister">用户注册</view>
				</view>
				<view class="botCpontent">
					<label>
						<checkbox value="cb" checked="checkxy" color="#409EFF" style="transform:scale(0.7)" class="marginRit10" />
						我已阅读
						<text class="marginRit10">并同意</text>
					</label>
					<text class="userzy marginRit10" @click="toUserAggree">《用户协议》</text>
				</view>
				<view class="Bottom">
					在北航天汇孵化器汇创云服务平台 (www.bbi.com.cn) 上已注册企业的用户，可通过账号登录或通过注册的手机号绑定微信后授权登录。
					未在汇创云服务平台上注册的企业，请先在网站 www.bbi.com.cn上或通过本小程序进行新企业用户注册后再进行用户登录。
				</view>
			</view>
		</view>
	</view>
</template>

<script>
import { mapMutations } from 'vuex';
import { Subscribe } from '@/common/subscript.js';
import md5 from '@/common/md5.js';
export default {
	data() {
		return {
			h: this.$h,
			checkxy: false
		};
	},
	onShow() {
		this.init();
	},

	methods: {
		//初始数据
		init() {
			var _this = this;
			_this.$util.request(_this.ServerUrl + 'webchuangyespace/spaceInfoMethod', { breedId: '15d6298f1b864b61bbd1ffa43ac0d9ad' }, 'GET', function(d) {}, null, res => {
				uni.hideLoading();
			});
		},
		//用户协议页面
		toUserAggree() {
			uni.navigateTo({
				url: '../../views/login/userAgreement'
			});
		},
		//账号密码登录页面
		loginSubmit() {
		uni.setEnableDebug({
		    enableDebug: true
		})
			uni.navigateTo({
				url: '../../views/login/sign'
			});
		},
		tonewPoint() {
			uni.navigateTo({
				url: '../../views/message/newPoint'
			});
		},
		appLoginWx() {
			// #ifdef MP-WEIXIN
			uni.getProvider({
				service: 'oauth',
				success: function(res) {
					if (~res.provider.indexOf('weixin')) {
						uni.login({
							provider: 'weixin',
							success: res2 => {
								uni.getUserInfo({
									provider: 'weixin',
									success: info => {
										uni.navigateTo({
											url: '../../views/login/choseSys'
										});
										//这里请求接口
										console.log(res2);
										console.log(info);
									},
									fail: () => {
										uni.showToast({ title: '微信登录授权失败', icon: 'none' });
									}
								});
							},
							fail: () => {
								uni.showToast({ title: '微信登录授权失败', icon: 'none' });
							}
						});
					} else {
						uni.showToast({
							title: '请先安装微信或升级版本',
							icon: 'none'
						});
					}
				}
			});
			//#endif
		},
		//新用户注册页面
		toUserRegister() {
			uni.navigateTo({
				url: '../../views/login/userInfo'
			});
		}
	}
};
</script>

<style lang="scss" scoped>
.page {
	background: #fff;
	.loginbgImg {
		position: absolute;
		top: 0;
		left: 0;
		width: 100%;
		height: 408rpx;
	}
}
.layout {
	position: relative;
	z-index: 2;
	.logo {
		width: 221rpx;
		height: 221rpx;
		margin: 90rpx auto 0 auto;
		background: RGBA(255, 255, 255, 0.2);
		padding: 15rpx;
		box-sizing: border-box;
		border-radius: 100%;
		// background: url(../../static/img/logo.png) no-repeat center;
		// background-size: 100%;
		.logo1 {
			width: 100%;
			height: 100%;
			background: #e2f3fe;
			border-radius: 100%;
			image {
				width: 70%;
				height: 70%;
			}
		}
	}

	.wrap {
		width: 710rpx;
		margin: 0 auto;
		position: relative;
		padding: 10rpx 30rpx 10rpx;
		.title {
			text-align: center;
			padding: 0 20rpx;
			font-weight: bold;
			font-size: 48rpx;
			color: $color;
			margin-bottom: 60rpx;
		}
		.logo {
			width: 536rpx;
			height: 95rpx;
			margin: auto;
			background: url(../../static/img/logo.png) no-repeat center;
			background-size: 100%;
		}
		.login {
			width: 580rpx;
			margin: 80rpx auto 0 auto;
			height: 96rpx;
			color: #fff;
			font-size: 36rpx;
			background-image: linear-gradient(to left, $color, #00aaff);
		}
		.wexColor {
			background-image: linear-gradient(to left, #51b067, #39b04b);
		}
		.cuIcon-weixin,
		.cuIcon-lock {
			font-size: 50rpx;
			margin-right: 10rpx;
		}
		.botCpontent {
			width: 580rpx;
			padding: 0 10rpx;
			box-sizing: border-box;
			margin: 40rpx auto 0 auto;
			.botCont {
				border-bottom: 1px solid #333;
				padding-bottom: 5rpx;
				font-size: 32rpx;
				font-weight: bold;
			}
			.userzy {
				color: #f76260;
				text-decoration: underline;
			}
		}
		.Bottom {
			width: 580rpx;
			padding: 0 10rpx;
			box-sizing: border-box;
			margin: 30rpx auto 0 auto;
			color: #ccc;
			font-size: 28rpx;
		}
	}
}
</style>
